#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

const int N=510,INF=1e9+7;

int dist[N],backup[N];
int n,m,k;

struct Edge{
	int a,b,w;
}edges[N*N];


void bellman_ford()
{
	fill(dist,dist+N,INF);
	dist[1]=0;
	
	for(int i=0;i<k;i++){
		memcpy(backup,dist,sizeof dist);
		for(int j=0;j<m;j++){
			int a=edges[j].a,b=edges[j].b,w=edges[j].w;
			dist[b]=min(dist[b],backup[a]+w);
		}
	}
}


int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<m;i++){
		int a,b,w;
		scanf("%d%d%d",&a,&b,&w);
		edges[i]={a,b,w};
	}
	
	bellman_ford();
	
	if(dist[n]>INF/2) printf("impossible");
	else  printf("%d",dist[n]);
	
	return 0;
}
